this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.Ui=this.BX.Landing.Ui||{};(function(e,t,r,n,a,i){"use strict";var s="/bitrix/js/landing/ui/field/paysystemsselectorfield/dist/image/default-pay-system-image.svg";var l,o,c,u,h;function d(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */d=function t(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function e(t,r,n){return t[r]=n}}function o(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,i=Object.create(a.prototype),s=new T(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return E()}for(r.method=a,r.arg=i;;){var s=r.delegate;if(s){var l=H(s,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var o=c(e,t,r);if("normal"===o.type){if(n=r.done?"completed":"suspendedYield",o.arg===u)continue;return{value:o.arg,done:r.done}}"throw"===o.type&&(n="completed",r.method="throw",r.arg=o.arg)}}}(e,r,s),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=o;var u={};function h(){}function p(){}function f(){}var b={};l(b,a,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(L([])));y&&y!==t&&r.call(y,a)&&(b=y);var m=f.prototype=h.prototype=Object.create(b);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(a,i,s,l){var o=c(e[a],e,i);if("throw"!==o.type){var u=o.arg,h=u.value;return h&&"object"==babelHelpers["typeof"](h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,l)}),(function(e){n("throw",e,s,l)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return n("throw",e,s,l)}))}l(o.arg)}var a;this._invoke=function(e,r){function i(){return new t((function(t,a){n(e,r,t,a)}))}return a=a?a.then(i,i):i()}}function H(e,t){var r=e.iterator[t.method];if(undefined===r){if(t.delegate=null,"throw"===t.method){if(e.iterator["return"]&&(t.method="return",t.arg=undefined,H(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=undefined),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;){if(r.call(e,n))return t.value=e[n],t.done=!1,t}return t.value=undefined,t.done=!0,t};return i.next=i}}return{next:E}}function E(){return{value:undefined,done:!0}}return p.prototype=f,l(m,"constructor",f),l(f,"constructor",p),p.displayName=l(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,s,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var s=new w(o(t,r,n,a),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(m),l(m,s,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e){t.push(r)}return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=L,T.prototype={constructor:T,reset:function e(t){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(P),!t)for(var n in this){"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=undefined)}},stop:function e(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function e(t){if(this.done)throw t;var n=this;function a(e,r){return l.type="throw",l.arg=t,n.next=e,r&&(n.method="next",n.arg=undefined),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],l=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(o&&c){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function e(t,n){for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=n&&n<=s.finallyLoc&&(s=null);var l=s?s.completion:{};return l.type=t,l.arg=n,s?(this.method="next",this.next=s.finallyLoc,u):this.complete(l)},complete:function e(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),u},finish:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),u}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var a=n.completion;if("throw"===a.type){var i=a.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function e(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=undefined),u}},e}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){babelHelpers.defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t){y(e,t);t.add(e)}function v(e,t,r){y(e,t);t.set(e,r)}function y(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function m(e,t,r){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return r}var g=new WeakMap;var w=new WeakMap;var H=new WeakMap;var S=new WeakMap;var P=new WeakMap;var T=new WeakMap;var L=new WeakSet;var E=new WeakSet;var k=new WeakSet;var I=new WeakSet;var O=new WeakSet;var x=new WeakSet;var F=new WeakSet;var z=new WeakSet;var _=new WeakSet;var j=new WeakSet;var G=new WeakSet;var D=new WeakSet;var B=new WeakSet;var W=new WeakSet;var M=new WeakSet;var C=new WeakSet;var N=function(e){babelHelpers.inherits(t,e);function t(){var e;var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,r));b(babelHelpers.assertThisInitialized(e),C);b(babelHelpers.assertThisInitialized(e),M);b(babelHelpers.assertThisInitialized(e),W);b(babelHelpers.assertThisInitialized(e),B);b(babelHelpers.assertThisInitialized(e),D);b(babelHelpers.assertThisInitialized(e),G);b(babelHelpers.assertThisInitialized(e),j);b(babelHelpers.assertThisInitialized(e),_);b(babelHelpers.assertThisInitialized(e),z);b(babelHelpers.assertThisInitialized(e),F);b(babelHelpers.assertThisInitialized(e),x);b(babelHelpers.assertThisInitialized(e),O);b(babelHelpers.assertThisInitialized(e),I);b(babelHelpers.assertThisInitialized(e),k);b(babelHelpers.assertThisInitialized(e),E);b(babelHelpers.assertThisInitialized(e),L);v(babelHelpers.assertThisInitialized(e),g,{writable:true,value:void 0});v(babelHelpers.assertThisInitialized(e),w,{writable:true,value:{active:[],recommended:[]}});v(babelHelpers.assertThisInitialized(e),H,{writable:true,value:void 0});v(babelHelpers.assertThisInitialized(e),S,{writable:true,value:void 0});v(babelHelpers.assertThisInitialized(e),P,{writable:true,value:void 0});v(babelHelpers.assertThisInitialized(e),T,{writable:true,value:3e3});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(e),g,Reflect.has(r,"disabledPaySystems")?r.disabledPaySystems:[]);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(e),H,Reflect.has(r,"onFetchPaySystemsError")?r.onFetchPaySystemsError:function(){});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(e),S,Reflect.has(r,"showMorePaySystemsBtn")?r.showMorePaySystemsBtn:false);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(e),P,Reflect.has(r,"morePaySystemsBtnSidePanelPath")?r.morePaySystemsBtnSidePanelPath:"");n.Dom.clean(e.getLayout());m(babelHelpers.assertThisInitialized(e),k,U).call(babelHelpers.assertThisInitialized(e),true);return e}babelHelpers.createClass(t,[{key:"getValue",value:function e(){return{allPaySystems:f({},babelHelpers.classPrivateFieldGet(this,w)),disabledPaySystems:babelHelpers.toConsumableArray(babelHelpers.classPrivateFieldGet(this,g))}}}]);return t}(t.BaseField);function X(){return BX.ajax.runAction("crm.api.form.paysystem.list",{json:{}}).then((function(e){return e.data}))}function A(){var e=this;return m(this,L,X).call(this).then((function(t){var r=babelHelpers.classPrivateFieldGet(e,w).active.map((function(e){return e.id})).sort();var n=t.active.map((function(e){return e.id})).sort();babelHelpers.classPrivateFieldSet(e,w,t);var a={paySystems:t,isUpdated:false};if(r.length!==n.length){a.isUpdated=true;return a}for(var i=0;i<r.length;i++){if(r[i]!==n[i]){a.isUpdated=true;return a}}return a}))["catch"]((function(t){babelHelpers.classPrivateFieldGet(e,H).call(e,t.errors)}))}function U(){var e=this;var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;if(t){n.Dom.clean(this.getLayout());m(this,M,re).call(this).show()}var a=t?Date.now()+r:null;return m(this,E,A).call(this).then(function(){var t=babelHelpers.asyncToGenerator(d().mark((function t(i){var s,l;return d().wrap((function t(o){while(1){switch(o.prev=o.next){case 0:s=i.paySystems,l=i.isUpdated;if(!l){o.next=9;break}n.Dom.clean(e.getLayout());m(e,M,re).call(e).show();a=a!==null?a:Date.now()+r;o.next=7;return new Promise((function(e){return setTimeout(e,a-Date.now())}));case 7:m(e,M,re).call(e).hide();m(e,I,Y).call(e);case 9:return o.abrupt("return",s);case 10:case"end":return o.stop()}}}),t)})));return function(e){return t.apply(this,arguments)}}())}function Y(){n.Dom.clean(this.getLayout());m(this,G,Z).call(this);m(this,O,R).call(this);if(babelHelpers.classPrivateFieldGet(this,S)&&babelHelpers.classPrivateFieldGet(this,P)){m(this,x,V).call(this)}}function R(){var e=this;babelHelpers.classPrivateFieldGet(this,w).recommended.forEach((function(t){n.Dom.append(m(e,z,J).call(e,t),e.getLayout())}))}function V(){n.Dom.append(m(this,F,q).call(this),this.getLayout())}function q(){var e=this;return this.cache.remember("showMorePaySystemsBtn",(function(){var t=n.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<button type="button" class="landing-ui-content-pay-system-more-ps">\n\t\t\t\t<span class="landing-ui-content-pay-system-more-ps-text">\n\t\t\t\t\t',"\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t"])),a.Loc.getMessage("LANDING_FORM_PAY_SYSTEMS_CONNECT_OTHER_PAY_SYSTEM"));t.onclick=function(){BX.SidePanel.Instance.open(babelHelpers.classPrivateFieldGet(e,P),{events:{onCloseComplete:function t(r){return m(e,C,ne).call(e,r)}}})};return t}))}function J(e){var t=this;return this.cache.remember("recommendedPaySystem:"+e.id,(function(){var r=m(t,W,te).call(t,e.title,e.image);var i=n.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="landing-ui-field-pay-system-selector-connect-recommended">\n\t\t\t\t\t\t',"\n\t\t\t\t\t</div>\n\t\t\t\t"])),a.Loc.getMessage("LANDING_FORM_PAY_SYSTEMS_CONNECT_RECOMMENDED_PAY_SYSTEM_TEXT"));n.Event.bind(i,"click",(function(){return BX.SidePanel.Instance.open(e.editPath,{events:{onCloseComplete:function e(r){m(t,j,Q).call(t,r)}}})}));n.Dom.append(i,r);return r}))}function K(e){var t=this;return this.cache.remember("formPaySystem:"+e.id,(function(){var r;var a=m(t,W,te).call(t,e.title,(r=e.image)!==null&&r!==void 0?r:s);var l=new i.SmallSwitch({value:m(t,D,$).call(t,e.id)});n.Dom.addClass(l.getLayout(),"landing-ui-field-pay-system-selector-ps-switch");n.Dom.append(l.getLayout(),a);l.subscribe("onChange",(function(){return m(t,B,ee).call(t,e)}));return a}))}function Q(e){m(this,k,U).call(this,false,babelHelpers.classPrivateFieldGet(this,T))}function Z(){var e=this;var t=function t(r,n){var a=m(e,D,$).call(e,r.id);var i=m(e,D,$).call(e,n.id);if(a!==i){return a?-1:1}return n.id-r.id};babelHelpers.classPrivateFieldGet(this,w).active.sort(t).forEach((function(t){n.Dom.append(m(e,_,K).call(e,t),e.getLayout())}))}function $(e){return!babelHelpers.classPrivateFieldGet(this,g).includes(e)}function ee(e){if(m(this,D,$).call(this,e.id)){babelHelpers.classPrivateFieldGet(this,g).push(e.id)}else{babelHelpers.classPrivateFieldGet(this,g).splice(babelHelpers.classPrivateFieldGet(this,g).indexOf(e.id),1)}this.emit("onChange")}function te(e,t){var r=n.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="landing-ui-field-pay-system-selector-ps-wrapper">\n\t\t\t\t<div class="landing-ui-field-pay-system-selector-ps-img"></div>\n\t\t\t</div>\n\t\t'])));n.Dom.append(n.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(['<img src="','">'])),t),r.children[0]);n.Dom.append(n.Tag.render(h||(h=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-field-pay-system-ps-title">',"</div>"])),n.Text.encode(e)),r);return r}function re(){var e=this;return this.cache.remember("loader",(function(){return new r.Loader({target:e.layout,size:50,mode:"inline",offset:{top:"5px",left:"250px"}})}))}function ne(e){m(this,k,U).call(this,false,babelHelpers.classPrivateFieldGet(this,T))}e.PaySystemsSelectorField=N})(this.BX.Landing.Ui.Field=this.BX.Landing.Ui.Field||{},BX.Landing.UI.Field,BX,BX,BX.Landing,BX.Landing.UI.Field);
//# sourceMappingURL=paysystemsselectorfield.bundle.map.js